using UnityEngine;
using System.Collections;
using AssemblyCSharp;

public class MainMenuSceneScript : MonoBehaviour {
	
	/*
	 -218	Start
	  	
	-262	About	

	-304	Quit

	JUMP 44
	 */
	public GUITexture menuSelect;
	public GUIText menuStartGame;
	public GUIText menuAbout;
	public GUIText menuQuitGame;
	
	public bool isStart = false;
	public bool isAbout = false;
	public bool isQuit = false;
	
	private float menuJump_Start = -218;
	private float menuJump_About = -262;
	private float menuJump_Quit = -304;
	
	public AudioSource audioSourceSwitch;
	public AudioSource audioSourceClick;
	// Sound
	public AudioClip soundClick;
	public AudioClip soundSwitchMenu;
	// Use this for initialization
	void Start () {
		menuStartGame.fontStyle = FontStyle.Normal;
		menuAbout.fontStyle = FontStyle.Normal;
		menuQuitGame.fontStyle = FontStyle.Normal;
		menuAbout.fontSize = 28;
		menuQuitGame.fontSize = 28;
		menuStartGame.fontSize = 28;
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	void OnGUI() {
		showMyWindow();
	}
	
	 void showMyWindow() {
		
	}
	
	void OnMouseDown() {
		int loadLevel = Application.loadedLevel;
		if(isStart) {
			audio.PlayOneShot(soundClick);
			audio.Play();
			Application.LoadLevel(loadLevel + 2);
		}
		if(isQuit) {
			audio.PlayOneShot(soundClick);
			audio.Play();
			Application.Quit();
		}
		if(isAbout) {
			audio.PlayOneShot(soundClick);
			audio.Play();
			Application.LoadLevel(loadLevel + 1);
		}
	}
	
	
	void OnMouseEnter() {
		// Start game
		float height = menuSelect.pixelInset.height;
		float width = menuSelect.pixelInset.width;
		float x = menuSelect.pixelInset.x;
		float y = 0;
		if(isStart) {	
			
			audio.PlayOneShot(soundSwitchMenu);
			audio.Play();
			menuSelect.pixelInset = new Rect(x,menuJump_Start,width,height);
		}
		// Is About
		if(isAbout) {
			audio.PlayOneShot(soundSwitchMenu);
			audio.Play();
			menuSelect.pixelInset = new Rect(x,menuJump_About,width,height);
		}
		// Is Quit
		if(isQuit) {
			audio.PlayOneShot(soundSwitchMenu);
			audio.Play();
			menuSelect.pixelInset = new Rect(x,menuJump_Quit,width,height);
		}
		setTextUnBold();
	}
	
	void OnMouseExit() {
	}
	
	void setTextUnBold() {
		menuStartGame.fontStyle = FontStyle.Normal;
		menuAbout.fontStyle = FontStyle.Normal;
		menuQuitGame.fontStyle = FontStyle.Normal;
		menuAbout.fontSize = 28;
		menuQuitGame.fontSize = 28;
		menuStartGame.fontSize = 28;
		// About
		if(isAbout) {
			menuAbout.fontStyle = FontStyle.Bold;
			menuAbout.fontSize = 30;
		}
		// Quit
		if(isQuit) {
			menuQuitGame.fontStyle = FontStyle.Bold;
			menuQuitGame.fontSize = 30;
		}
		// Start
		if(isStart) {
			menuStartGame.fontStyle = FontStyle.Bold;
			menuStartGame.fontSize = 30;
		}
	}
}
